package com.cskaoyan.mall.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cskaoyan.mall.user.converter.UserAddressConverter;
import com.cskaoyan.mall.user.mapper.UserAddressMapper;
import com.cskaoyan.mall.user.model.UserAddress;
import com.cskaoyan.mall.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Pudding
 * @Date 2024/7/17 10:30
 */
@Service
public class UserAddressServiceImpl implements UserAddressService {

    @Autowired
    UserAddressMapper userAddressMapper;
    @Autowired
    UserAddressConverter userAddressConverter;

    @Override
    public List<UserAddress> findUserAddressListByUserId(String userId) {

        //1. 根据userId查询user中address
        LambdaQueryWrapper<UserAddress> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UserAddress::getUserId, Long.parseLong(userId));

        List<UserAddress> userAddressList = userAddressMapper.selectList(lambdaQueryWrapper);
        return userAddressList;
    }
}
